import request from '@/utils/request'
import { AxiosResponse } from 'axios'

// 项目用户相关的请求地址
enum Email_API {
  GET_BINDING_EMAIL_CAPTCHA = '/transaction_assistant/email/captcha/bindingEmail/{email}',
  GET_LOGIN_EMAIL_CAPTCHA = '/transaction_assistant/email/captcha/login/{email}',
  GET_NEW_EMAIL_CAPTCHA = '/transaction_assistant/email/captcha/newEmail/{email}',
  GET_OLD_EMAIL_CAPTHCA = '/transaction_assistant/email/captcha/oldEmail/{email}',
  GET_PWD_EMAIL_CAPTHCA = '/transaction_assistant/email/captcha/pwd/{email}',
}

/**
 * 绑定邮箱验证码
 * @param {string} email
 * @returns
 */
export const reqGetBindingEmailCaptcha = (email: string) =>
  request.get<any, AxiosResponse<any>>(
    Email_API.GET_BINDING_EMAIL_CAPTCHA.replace('{email}', email),
  )

/**
 * 登录邮箱验证码
 * @param {string} email
 * @returns
 */
export const reqGetLoginEmailCaptcha = (email: string) =>
  request.get<any, AxiosResponse<any>>(
    Email_API.GET_LOGIN_EMAIL_CAPTCHA.replace('{email}', email),
  )

/**
 * 新邮箱验证码
 * @param {string} email
 * @returns
 */
export const reqGetNewEmailCaptcha = (email: string) =>
  request.get<any, AxiosResponse<any>>(
    Email_API.GET_NEW_EMAIL_CAPTCHA.replace('{email}', email),
  )

/**
 * 旧邮箱验证码
 * @param {string} email
 * @returns
 */
export const reqGetOldEmailCaptcha = (email: string) =>
  request.get<any, AxiosResponse<any>>(
    Email_API.GET_OLD_EMAIL_CAPTHCA.replace('{email}', email),
  )

/**
 * 密码邮箱验证码
 * @param {string} email
 * @returns
 */
export const reqGetChangePwdCaptcha = (email: string) =>
  request.get<any, AxiosResponse<any>>(
    Email_API.GET_PWD_EMAIL_CAPTHCA.replace('{email}', email),
  )
